/*
 * @description: 仅编写图表公共类型定义，各类图表独有的写入各图表的base组件中
 * @fileName: charTypes.ts
 * @params
 * @author: lxx
 * @date: 2025-04-16 16:27:44
 * @version: V1.0.0
 */
import type { ECBasicOption } from 'echarts/types/dist/shared'
export type chartItemType = 'line' | 'bar' | 'pie'
export const LineChart: chartItemType = 'line'
export const BarChart: chartItemType = 'bar'
export const PieChart: chartItemType = 'pie'

// 数据的类型定义
export interface chartDataInt {
  name: string
  value: number
}

export interface ChartPropsInt {
  // 宽度
  width?: string
  // 高度
  height?: string
  // 边距
  grid?: {
    top: string
    right: string
    bottom: string
    left: string
  }
  // x轴数据
  xAxisData?: string[]
  // 图标数据
  chartData?: chartDataInt[] | chartDataInt[][]
  // 是否显示图例
  legendShow?: boolean
  // 图表使用的主体颜色
  color?: string | string[]
  // 图表类型
  chartType?: chartItemType
  // 自定义处理图标数据方法
  customizeDataFun?: (chartData: chartDataInt[] | chartDataInt[][]) => { name: string; value: number; [k: string]: any }[]
}

export interface chartOptionsInt extends ECBasicOption {
  tooltip?: {
    trigger: string
  }
  grid:
    | {
        top: string
        right: string
        bottom: string
        left: string
      }
    | undefined
  xAxis: {
    show: boolean
    axisTick: boolean
    axisLine: {
      lineStyle: {
        color: string | undefined
      }
    }
    axisLabel: {
      color: string
    }
    type: string
    data: string[] | undefined
  }
  yAxis: {
    show: boolean
    axisLine: {
      show: boolean
      lineStyle: {
        color: string | undefined
      }
    }
    axisLabel: {
      color: string
      formatter: (value: number) => number | ''
    }
    splitLine: {
      show: boolean
      lineStyle: {
        type: string
        color: string | undefined
      }
    }
  }
  series: {
    type: chartItemType
    [k: string]: any
  }[]
}
